import {configurationSelect} from "@/api/configs";


/**
 * 获取源数据
 * 1、加载收集渠道数据
 * 2、加载数据处理活动周期
 * 3、加载数据处理活动类型
 * @param Lang
 * @returns {Promise<{collectionChannelsSourceData: undefined, dataProcessingActivityCycleData: undefined, processingActivityTypesData: undefined}>}
 */
export async function getSourceData(Lang) {
    var result = {
        collectionChannelsSourceData: undefined,
        dataProcessingActivityCycleData: undefined,
        processingActivityTypesData: undefined
    }
    // 加载收集渠道数据
    const { data: collectionChannelsSourceData } =
        await configurationSelect({ state: 5 });
    result.collectionChannelsSourceData = collectionChannelsSourceData;

    if (Lang && !JSON.parse(Lang)) {
        // 加载数据处理活动周期
        const { data: dataProcessingActivityCycleData } =
            await configurationSelect({ state: 6, types: 1 });
        result.dataProcessingActivityCycleData =
            dataProcessingActivityCycleData;
        // 加载数据处理活动类型
        const { data: processingActivityTypesData } =
            await configurationSelect({ state: 7, types: 1 });
        result.processingActivityTypesData = processingActivityTypesData;
    } else {
        // 加载数据处理活动周期
        const { data: dataProcessingActivityCycleData } =
            await configurationSelect({ state: 6 });
        result.dataProcessingActivityCycleData =
            dataProcessingActivityCycleData;
        // 加载数据处理活动类型
        const { data: processingActivityTypesData } =
            await configurationSelect({ state: 7 });
        result.processingActivityTypesData = processingActivityTypesData;
    }
    return result;
}